package com.kexio.enterprise.governance.ratelimit.config;

import com.kexio.enterprise.governance.ratelimit.enums.RateLimitAlgorithm;

import java.util.Map;

/**
 * 限流配置
 * 
 * @author Kexio
 * @since 1.0.0
 */
public class RateLimitConfig {
    private RateLimitAlgorithm algorithm;
    private long capacity; // 桶容量或窗口大小
    private long refillRate; // 令牌补充速率（每秒）
    private long windowSizeMs; // 窗口大小（毫秒）
    private long initialTokens; // 初始令牌数
    private boolean enableStatistics; // 是否启用统计
    private boolean enableWarmup; // 是否启用预热
    private long warmupPeriodMs; // 预热期间（毫秒）
    private double warmupFactor; // 预热因子
    private Map<String, Object> customParams; // 自定义参数

    public RateLimitConfig() {
        this.algorithm = RateLimitAlgorithm.TOKEN_BUCKET;
        this.capacity = 100;
        this.refillRate = 10;
        this.windowSizeMs = 1000;
        this.enableStatistics = true;
        this.enableWarmup = false;
        this.warmupPeriodMs = 0;
        this.warmupFactor = 1.0;
    }

    // Getters and Setters
    public RateLimitAlgorithm getAlgorithm() { return algorithm; }
    public void setAlgorithm(RateLimitAlgorithm algorithm) { this.algorithm = algorithm; }
    
    public long getCapacity() { return capacity; }
    public void setCapacity(long capacity) { this.capacity = capacity; }
    
    public long getRefillRate() { return refillRate; }
    public void setRefillRate(long refillRate) { this.refillRate = refillRate; }
    
    public long getWindowSizeMs() { return windowSizeMs; }
    public void setWindowSizeMs(long windowSizeMs) { this.windowSizeMs = windowSizeMs; }
    
    public long getInitialTokens() { return initialTokens; }
    public void setInitialTokens(long initialTokens) { this.initialTokens = initialTokens; }
    
    public boolean isEnableStatistics() { return enableStatistics; }
    public void setEnableStatistics(boolean enableStatistics) { this.enableStatistics = enableStatistics; }
    
    public boolean isEnableWarmup() { return enableWarmup; }
    public void setEnableWarmup(boolean enableWarmup) { this.enableWarmup = enableWarmup; }
    
    public long getWarmupPeriodMs() { return warmupPeriodMs; }
    public void setWarmupPeriodMs(long warmupPeriodMs) { this.warmupPeriodMs = warmupPeriodMs; }
    
    public double getWarmupFactor() { return warmupFactor; }
    public void setWarmupFactor(double warmupFactor) { this.warmupFactor = warmupFactor; }
    
    public Map<String, Object> getCustomParams() { return customParams; }
    public void setCustomParams(Map<String, Object> customParams) { this.customParams = customParams; }
}
